package com.santu.edu.supporter.biz.good.controller;

import com.santu.edu.supporter.biz.good.pojo.dto.GoodDTO;
import com.santu.edu.supporter.biz.good.pojo.params.GoodAddParam;
import com.santu.edu.supporter.biz.good.pojo.params.GoodUpdateParam;
import com.santu.edu.supporter.biz.good.service.GoodService;
import com.santu.edu.supporter.biz.user.pojo.dto.UserAddressDTO;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * @author luoyaoqi
 * @createTime 2024/3/12
 * @description
 */
@RestController
@Validated
@RequiredArgsConstructor
@RequestMapping("good")
public class GoodController {

    private final GoodService goodService;

    @PostMapping("add")
    public Boolean addUserAddress(@RequestBody @Valid GoodAddParam addParam) {
        return goodService.addGood(addParam);
    }

    @PostMapping("update")
    public Boolean updateUserAddress(@RequestBody @Valid GoodUpdateParam updateParam) {
        return goodService.updateGood(updateParam);
    }

    @PostMapping("remove")
    public Boolean removeUserAddress(@NotBlank(message = "addressId不能为空") String goodId) {
        return goodService.removeGood(goodId);
    }


    @GetMapping("get/good/by/categoryId")
    public List<GoodDTO> getUserAddressList(@NotBlank(message = "categoryId") String categoryId) {
        return goodService.getGoodList(categoryId);
    }


}
